﻿using System;
using System.Collections.Generic;
using System.Text;

namespace StockTrader.BusinessService.DataContract.HnxInfo
{
    public class HnxMarketData
    {
        public DateTime TradingDate { set; get; }
        public string Time { set; get; }
        public string Status { set; get; }
        public long Trade { set; get; }
        public int Stock { set; get; }
        public long Qtty { set; get; }
        public decimal Value { set; get; }

        public int Advance { set; get; }
        public int Nochange { set; get; }
        public int Decline { set; get; }
        public decimal Chg { set; get; }
        public decimal Pct { set; get; }
        public decimal Market { set; get; }
        public decimal BaseIndex { set; get; }
        public decimal High { set; get; }
        public decimal Low { set; get; }
        public long DateNo { set; get; }
        public long Pt { set; get; }
        public int PtTrade { set; get; }
        public decimal PtValue { set; get; }
        public long TimeStamp { set; get; }

        public HnxMarketData() { }

        public HnxMarketData(DateTime trading, string time, decimal status, decimal trade, decimal stock, decimal qtty, decimal vl, decimal advan, decimal nochange, decimal decline, decimal chg, decimal pct, decimal market, decimal baseindex, decimal high, decimal low, decimal dateno, decimal pt, decimal pttrade, decimal ptvalue)
        {
            this.TradingDate = trading;
            this.Time = time;

            switch (Convert.ToInt32(status))
            {
                case 1:
                    this.Status = "BoD";
                    break;
                case 2:
                    this.Status = "Opening";
                    break;
                case 3:
                    this.Status = "Accept ATO";
                    break;
                case 4:
                    this.Status = "ATO";
                    break;
                case 5:
                    this.Status = "Trading";
                    break;
                case 6:
                    this.Status = "Stop accept order";
                    break;
                case 7:
                    this.Status = "Accept orders";
                    break;
                case 8:
                    this.Status = "Accept ATC orders";
                    break;
                case 9:
                    this.Status = "ATC";
                    break;
                case 10:
                    this.Status = "Inter-break";
                    break;
                case 11:
                    this.Status = "Post orders";
                    break;
                case 12:
                    this.Status = "Trade by trade";
                    break;
                case 13:
                    this.Status = "Closed";
                    break;
                case 14:
                    this.Status = "Normal phase";
                    break;
                case 15:
                    this.Status = "EndOfDay";
                    break;
                case 16:
                    this.Status = "Phase break";
                    break;
                default:
                    this.Status = "Unknown";
                    break;
            }
            this.Trade = Convert.ToInt64(trade);
            this.Stock = Convert.ToInt32(stock);
            this.Qtty = Convert.ToInt64(qtty);
            this.Value = vl;
            this.Advance = Convert.ToInt32(advan);
            this.Nochange = Convert.ToInt32(nochange);
            this.Decline = Convert.ToInt32(decline);
            this.Chg = chg; this.Pct = pct;
            this.Market = market;
            BaseIndex = baseindex;
            this.High = high; this.Low = low;
            this.DateNo = Convert.ToInt64(dateno);
            this.Pt = Convert.ToInt64(pt);
            this.PtTrade = Convert.ToInt32(pttrade);
            this.PtValue = ptvalue;
            this.TimeStamp = DateTime.Now.Ticks;
        }

        public override bool Equals(object obj)
        {
            if (TradingDate.Equals(((HnxMarketData)obj).TradingDate))
                if (Time.Equals(((HnxMarketData)obj).Time))
                    return Status.Equals(((HnxMarketData)obj).Status);
                else
                    return Time.Equals(((HnxMarketData)obj).Time);
            else
                return TradingDate.Equals(((HnxMarketData)obj).TradingDate);
        }

    }
}
